<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String msg=(String)request.getAttribute("msg");
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'login1.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link rel="stylesheet" type="text/css" href="css/bootstrap.css"/>
		<script type="text/javascript" src="js/jquery-1.8.3.min.js">
			
		</script>
		<script type="text/javascript" src="js/bootstrap.js">
			
		</script>

  </head>
  
  <body>
   <div style="min-width: 1100px;">
		<div style="width: 400px ;margin: 0 auto;border: 1px solid #cccccc;padding-right: 40px;padding: 47px 100px 0px 0px;margin-top: 10%;">
			<form class="form-horizontal" action="login1.html" method="post">
			<div class="control-group">
				<label class="control-label">账号</label>
				<div class="controls">
					<input type="text" name="username" id="usename" required="required" placeholder="请输入账号">
					
				</div>
			</div>
			<div class="control-group">
				<label class="control-label">密码</label>
				<div class="controls">
					<input type="password" name="password" id="password" required="required" placeholder="请输入密码">
				</div>
			</div>
			<div class="control-group">
				<label class="control-label">验证码</label>
				<div class="controls">
					<input type="text" name="valueCode" id="valueCode" onkeyup="ajxValueCode() " required="required" placeholder="请输入验证码">
				</div>
			</div>
			<div class="img">
			<img src="identity.html" id="image" onclick="ChangeCode()"/>
			</div>
			 
			<div class="control-group">
				<div class="controls">
					<input type="submit" class="btn btn-success " value="登陆">
				</div>
			</div>
		</form>
		</div>
		</div>
  </body>
   <script><!--
  var msg="<%=msg%>";              
  if(msg!="null"){             //一开始用request接收mg的value值，如果不是空则弹出对话框
  alert(msg);
  }
  function ChangeCode(){                          //点击图片就重新调用identityservlet重新产生一张随机图片
  image=document.getElementById("image");
  image.src="identity.html?time="+new Date();    //参数变化则可以刷新页面
  } 
  function  ajxValueCode(){               //当输入4个字符时自动比较
  	var valueCode=document.getElementById("valueCode").value; //获得属性值
				if(valueCode.length>0&&valueCode.length==4){  
					var xmlhttp=null;
					if (window.XMLHttpRequest){
						xmlhttp=new XMLHttpRequest();
					}else{
						xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
					}
					xmlhttp.open("GET","<%=basePath%>value.html?valueCode="+valueCode,false); 
					xmlhttp.send();
					var data=xmlhttp.responseText; 
					//alert(data);
					var json=JSON.parse(data);  //把data解析为json
				//	alert(json.flag);
					if(json.flag==false){ 
						alert(json.msg);
					/*  document.getElementById("validateCode").value="";
						document.getElementById("validateCode").focus();*/
					}
				}else{
				}
  	
  
  }
  --></script>
</html>
